home *** CD-ROM | disk | FTP | other *** search
- /*
- Pencil V1.0, Copyright 1994, 95 by Florian Marquardt.
- This program may be distributed under the terms of the GNU general
- public license (Start Pencil and select "Info>COPYING..." for a copy of the
- license).
- */
- #import "Group.h"
-
- extern BOOL globalOutlines;
-
- @implementation Group
- - (void)draw:(NXRect *)re
- {
- int i, c=[slist count];
-
- switch(type)
- {
- case PENCIL_STANDARD_GROUP:
- for(i=0;i<c;i++) [[slist objectAt:i] draw:re]; break;
- case PENCIL_CLIP_GROUP:
- PSgsave();
- [[slist objectAt:0] drawPath];
- if(globalOutlines)
- DPSPrintf(DPSGetCurrentContext(), " clip 0 setgray 0 setlinewidth stroke ");
- else
- DPSPrintf(DPSGetCurrentContext(), " clip newpath ");
- for(i=1;i<c;i++) [[slist objectAt:i] draw:re];
- PSgrestore();
- break;
- }
- }
- - setGroupType:(char)typ { sx=sy=1; type=typ; if(type==PENCIL_CLIP_GROUP && [slist count]) [[slist objectAt:0] setDrawingMethod:"drawF"]; return self; }
- - select:(BOOL)yesno { selected=yesno; return self; }
- - free
- {
- int i;
- if(slist)
- {
- i=[slist count];
- while(i--) [[slist objectAt:i] free];
- [slist free];
- }
- return [super freeOrig];
- }
- - (void)drawControl:(NXRect *)re:(int)cp:(float)bsize
- {
- [self draw:re];
- [self calculateBoundingBox:nil];
- PSsetgray(.3); PSsetlinewidth(0);
- PSrectstroke(bounds.origin.x, bounds.origin.y, bounds.size.width, bounds.size.height);
- }
- - freeLeaveObjects
- {
- if(slist)
- [slist free];
- return [super freeOrig];
- }
- - write:(NXTypedStream *)stream
- {
- [super write:stream];
- NXWriteType(stream,"c",&type);
- return self;
- }
-
- - read:(NXTypedStream *)stream
- {
- [super read:stream];
- NXReadType(stream,"c",&type);
- return self;
- }
-
- - (BOOL)selected:(NXEvent *)te:(int *)cp:(id)view
- {
- if(type==PENCIL_CLIP_GROUP)
- {
- return [[slist objectAt:0] selected:te:cp:view];
- }
- else
- return [super selected:te:cp:view];
- }
-
- - (void)writeType:(NXStream *)to
- {
- NXPrintf(to,"2");
- }
-
- - (void)writeDescription:(NXStream *)to
- {
- int i;
-
- [super writeDescription:to];
- NXPrintf(to, " %d ", [slist count]);
- for(i=0;i<[slist count];i++) [[slist objectAt:i] writeDescription:to];
- }
-
- @end
-